﻿Public Class DataSource



    Public Overridable ReadOnly Property Type As String
        Get
            Return ""
        End Get
    End Property

    Public Overridable ReadOnly Property OutDated As Boolean
        Get
            Return False
        End Get
    End Property

    Public Overridable Property Name As String
    Public Overridable Property DataSourceName As String
    Public Overridable Property Columns As IEnumerable(Of DataSourceColumn)
    Public Overridable Property Data As DataTable
    Public Overridable Property IsDatabase As Boolean


    Public Overridable Sub Save(ByVal container As XElement)
        container.@Name = Me.Name
        container.@DataSourceName = Me.DataSourceName
        container.@Type = Me.Type
        container.@IsDatabase = Me.IsDatabase
        container.@OutDated = Me.OutDated
    End Sub
    Public Overridable Sub Load(ByVal container As XElement)

    End Sub
    Public Overridable Function Query(ByVal txt As String) As DataTable
        Return Nothing
    End Function
    Public Overridable Function Query(ByVal SqlQueryData As SqlQueryData) As DataTable
        Return Nothing
    End Function
End Class

Public Class IndicateurDataSource
    Inherits DataSource

    Public Overrides ReadOnly Property Type As String
        Get
            Return "Indicateurs"
        End Get
    End Property

    Public Overrides Property Columns As System.Collections.Generic.IEnumerable(Of DataSourceColumn)
        Get
            Return (From i In ModuleDashboarding._activeproject.IndicateurList
                    Where i.Type = "Formula"
                    Select New DataSourceColumn() With {.Name = i.Name, .RuntimeType = GetType(Double)}).ToList()
        End Get
        Set(ByVal value As System.Collections.Generic.IEnumerable(Of DataSourceColumn))
        End Set
    End Property
End Class